import send_msg from '@feidao-factory/send-msg';

const GET_OPENID_CODE_NODEJS = 'thirdpart.usecodegetwxservice.intranet';

/**
 * 通过code获取openid
 * @param action_id 系统参数action_id
 * @param session_id 系统参数session_id
 * @param spaceid 系统参数spaceid
 * @param code code
 * @example get_openid_by_code(action_id, session_id, spaceid, code);
 */
export default async function get_openid_by_code(action_id: string, session_id: string, spaceid: string, code: string) {
	const msg = {
		client_type: 'weixin_pub',
		code,
		flag: '101',
		spaceid
	};
	return await send_msg(action_id, session_id, GET_OPENID_CODE_NODEJS, msg);
}
